<template>
    <div>
        <h1>所选课程</h1>
        <br>
        <table border="1">
            <!-- <tr>
                <td>
                    <input type="text" v-model="sousuo">
                    <button @click="ss(uid)">搜索</button>
                </td>
            </tr> -->
            <tr>
                <td>序号</td>
                <td>课程名称</td>
                <td>内容</td>
                <td>操作</td>
            </tr>
            <tr v-for="(i,index) in course_list">
                <td>{{index+1}}</td>
                <td>{{i.title}}</td>
                <td>{{i.content}}</td>
                <td>
                    <button @click="del(uid)">删除</button>
                </td>
            </tr>
        </table>
    </div>
</template>

<script>
export default {
    data:function(){
        return{
            course_list:[],
            // sousuo:"",
            uid:""
        }
    },
    methods:{
        del:function(uid){
            this.axios({
                url:"http://127.0.0.1:8000/del/",
                method:'post',
                data:{"uid":uid}
            }).then((res)=>{
                if(res.data.code==200){
                    alert('成功')
                }else{
                    alert(res.data.message)
                }
            })
        },

        init:function(){
            var uid = JSON.parse(sessionStorage.getItem('uid'))
            var course_list = JSON.parse(sessionStorage.getItem('coursr'))
            
            // var course_list = this.$route.query.course
            this.uid = uid
            this.course_list = course_list
            console.log(course_list)
            
        }
    },
    mounted:function(){
        this.init()
    }
}
</script>
